<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="welcome">
    <h1>hello world</h1>
    <div>
        <p>jquery.component.js</p>
    </div>
</div>

<script src="jquery-3.1.0.js"></script>
<script src="jquery.component.js"></script>
<script>
    var welcome = $('.welcome').component({
        on: [
            {
                selector: '',
                events: 'mouseenter',
                data: {message: '我是:'},
                handler: function (e) {
                    console.log(e.data.message)
                    console.log(this)
                }
            },
            {
                selector: 'h1',
                events: 'click',
                data: {message: '我是:'},
                handler: function (e) {
                    console.log(e.data.message)
                    console.log(this)
                }
            },
        ],
        methods: {
            sayName: function () {
                console.log('我是:')
                console.log(this)
            },
        }
    })

    // 调用welcome的一个方法
    welcome.sayName()
</script>
</body>
</html>